package com.thinkgem.jeesite.modules.book.service;

import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.book.dao.PrintTemplateDao;
import com.thinkgem.jeesite.modules.book.entity.PrintTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 流程模型相关Controller
 * @author ThinkGem
 * @version 2013-11-03
 */
@Service
@Transactional(readOnly = true)
public class PrintTemplateService extends CrudService<PrintTemplateDao, PrintTemplate> {

    public List<PrintTemplate> searchPrintTemplates(){
        return dao.searchPrintTemplates();
    }

    /**
     * 保存数据（插入或更新）
     * @param entity
     */
    @Transactional()
    public void save(PrintTemplate entity){
        if(entity.getIsNewRecord()){
            entity.preInsert();
            dao.insert(entity);
        }
        else{
            entity.preUpdate();
            dao.update(entity);
        }
    }
}
